package com.xiaobaibai.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.xiaobaibai.valid.AddGroup;
import com.xiaobaibai.valid.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author xiaobaibai
 * @since 2020-10-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("user_address")
@ApiModel(value="UserAddress对象", description="")
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class UserAddress implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "地址主键")
    @TableId(value = "id", type = IdType.AUTO)
    @Null(message = "新增不可指定id",groups = AddGroup.class)
    @NotNull(message = "修改需指定id",groups = UpdateGroup.class)
    private Integer id;

    @ApiModelProperty(value = "用户id")
    @TableField("user_id")
//    @NotNull(message = "请填写指定用户id",groups = AddGroup.class)//有了security不需要userId了
    private Integer userId;

    @ApiModelProperty(value = "用户姓名")
    @TableField("user_name")
    @NotNull(message = "请填写姓名",groups = AddGroup.class)
    @Size(max = 10,message = "姓名过长")
    private String userName;

    @ApiModelProperty(value = "用户手机号")
    @TableField("user_phone")
    @NotNull(message = "请填写手机号",groups = AddGroup.class)
    @Pattern(regexp = "^1[1-9][0-9]\\d{8}$",message = "请填写正确的手机号",groups = {AddGroup.class,UpdateGroup.class})
    private String userPhone;

    @ApiModelProperty(value = "详细地址")
    @TableField("user_address_detail")
    @NotNull(message = "请填写详细地址",groups = AddGroup.class)
    @Size(max = 40,message = "地址过长")
    private String userAddressDetail;

    @ApiModelProperty(value = "是否默认0非1默认")
    @TableField("flag")
    private Boolean flag;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;


}
